
<?php
$model = new BDynamicFormModel();
$timeSlotUnitField = 'media_timeSlotUnit_analyse_total_bill';
$timeSlotCountField = 'media_timeSlotCount_analyse_total_bill';
$endTimeField = 'media_endTime_analyse_total_bill';
$customerGroupField = 'media_customerGroup_analyse_total_bill';
$model->addField($timeSlotUnitField);
$model->addField($timeSlotCountField);
$model->addField($endTimeField);
$model->addField($customerGroupField);
?>
<div class="well">
    <div class="control-group">
        <label for="timeSlotUnit">时间单位：</label>
        <?php echo CHtml::activeDropDownList($model, $timeSlotUnitField, array('day' => '天', 'week' => '星期', 'month' => '月'), array('id' => 'timeSlotUnit', 'class' => 'span2')); ?>
        <?php echo CHtml::activeTextField($model, $timeSlotCountField, array('class' => 'span3', 'placeholder' => '时间单位次数')); ?>
        <?php echo CHtml::activeTextField($model, $endTimeField, array('class' => 'span4', 'placeholder' => '结束时间，yyyymmdd')); //这里加上时间输入控件 ?>
        <a href="#" rel="tooltip" title="
           [从结束时间往前推，如果没有指定结束时间，就以当前时间计算]" >说明</a>
    </div>
    <div class="control-group">
        <label for = "customerGroup">选择客户群：</label>
        <?php
        echo CHtml::activeDropDownList($model, $customerGroupField, array('all' => '所有客户', 'member' => '会员', 'notMember' => '非会员'), array('id' => 'customerGroup', 'class' => 'span3'));
        echo $control->getAjaxLink('分析', array(
            'cooker' => 'BCafeBill@showBillAnalyseTotalBill',
            'htmlOptions' => array('class' => 'btn btn-primary')
        ));
        ?>
    </div>

</div>
<ul class="breadcrumb">
    <li class="active">
        <?PHP
        echo $control->getAjaxLink(
                '10天营业额变化', array('cooker' => 'BCafeBill@showBillAnalyseTotalBill',
            'period' => '10days'));
        ?> <span class="divider">｜</span>
    </li>
    <li>
        <?PHP
        echo $control->getAjaxLink(
                '20天营业额变化', array('cooker' => 'BCafeBill@showBillAnalyseTotalBill',
            'period' => '20days'));
        ?><span class="divider">｜</span> 
    </li>
    <li>
        <?PHP
        echo $control->getAjaxLink(
                '6个星期营业额变化', array('cooker' => 'BCafeBill@showBillAnalyseTotalBill',
            'period' => '6weeks'));
        ?><span class="divider">｜</span> 
    </li>
    <li>
        <?PHP
        echo $control->getAjaxLink(
                '6个月营业额变化', array('cooker' => 'BCafeBill@showBillAnalyseTotalBill',
            'period' => '6months'));
        ?>
    </li>
</ul>
<?php if (!isset($analyseTotalData) || $analyseTotalData['chartPeriodData'] == NULL) { ?>
    <div class="well-small">
        <h5 class="text-error">请输入正确数据！</h5>
    </div>
<?php } else { ?>
    <div>
        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl . '/js/mobile/Chart.min.js' ?>"></script>
        <p><?php echo $analyseTotalData['chartTitle']; ?></p>
        <p style="margin-top: 60px;float: left;width: 20px"><?php echo $analyseTotalData['Y_axis']; ?></p>
        <canvas id="chart-line" width="300" height="200"></canvas>
        <p style="margin-left: 150px;"><?php echo $analyseTotalData['X_axis']; ?> </p>
        <script>
            var data = {
                labels: [<?php
    $periodData = $analyseTotalData['chartPeriodData'];
    foreach ($periodData as $period) {
        echo '"' . $period . '",';
    }
    ?>],
                datasets: [
                    {
                        label: "My Second dataset",
                        fillColor: "rgba(151,187,205,0.2)",
                        strokeColor: "rgba(151,187,205,1)",
                        pointColor: "rgba(151,187,205,1)",
                        pointStrokeColor: "#fff",
                        pointHighlightFill: "#fff",
                        pointHighlightStroke: "rgba(151,187,205,1)",
                        data: [<?php
    foreach ($analyseTotalData['chartValueData'] as $value) {
        echo $value . ',';
    }
    ?>]
                    }
                ]
            };
            function addChart() {

                var ctx1 = document.getElementById("chart-line").getContext("2d");
                var myLineChart = new Chart(ctx1).Line(data, {
                    segmentShowStroke: true
                });
            }
            ;
            addChart();
        </script>
    </div>
<?php } ?>

